<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

 <style>
	#cacheDiv {
	font-size:14px;
  width: 100%; height: 100%;
  border: 0; padding: 5; margin: 0;
}
	
	</style>
</head>
<body class="nihilo">


<div dojoType="dijit.TitlePane" open="false" title="功能说明" style="width:300px;height:300px;float:right">
	<ul>
	页面缓存设置。
	<li>1、支持本地硬盘存储</li>
	<li>2、支持memcached分布式内存缓存</li>
	<li>3、支持自定义页面缓存</li>
	
	</ul>
  
</div>
		

	
	<div style="margin:10px;">位置: 缓存管理  > 页面缓存设置</div>
	<div style="margin:10px;">
		<button dojoType="dijit.form.Button" onclick="dijit.byId('newPageRule').show();">新建规则</button>
	</div>
	
	<table style="width:600px;margin:10px">
		<thead>
		<tr >
		<td style="border-bottom:1px solid #ccc;width:450px;background-color:#eee">规则</td>
		
		<td style="border-bottom:1px solid #ccc;width:150px;background-color:#eee">操作</td>
		</tr>
		</thead>
		<tbody id="pagerulelist">
		<?php foreach($rules as $item){?>
		<tr id="page_<?=$item['rule_name']?>">
		<td><?=$item['rule_name']?></td>
		<td><button dojoType="dijit.form.Button" onclick="editPageRule('page_<?=$item['rule_name']?>','<?=$item['rule_name']?>');">修改</button><button dojoType="dijit.form.Button" onclick="deletePageRule('page_<?=$item['rule_name']?>','<?=$item['rule_name']?>');">删除</button></td>
		</tr>
		<? }?>
		</tbody>
	</table>
	
		

	



<div dojoType="dijit.Dialog" id="newPageRule" title="新建规则" >
	
	<div method="" jsid="page_form" id="page_form" dojoType="dijit.form.Form" action="">
	
	<script type="dojo/method" event="onSubmit">
		if (this.validate()) {
            var xhrArgs = {
					url:gSiteUrl+"/index.php",
        	        form: 'page_form',
        	        handleAs: "json",
        	        load: function(data){
    	      			
						if(data.s==200){
	            			//新增行
			            	var rowid= "page_"+data.d;
			            	var rulename = data.d;
			            	
			            	var row=document.createElement("tr");   
			            	row.id= rowid; 
		
			            	var td = document.createElement("td");
			            	var textNode = document.createTextNode(rulename);
			            	td.appendChild(textNode);
			            	row.appendChild(td);
			            	
			            	var td = document.createElement("td");
			            	var editbtn =new dijit.form.Button({label:"修改",onClick:function(){editPageRule(rowid,rulename)}});
			            	var deletebtn =new dijit.form.Button({label:"删除",onClick:function(){deletePageRule(rowid,rulename)}});
			            	td.appendChild(editbtn.domNode);
			            	td.appendChild(deletebtn.domNode);
			            	row.appendChild(td);		            	
			            	dojo.byId('pagerulelist').appendChild(row);
	
			            	//表单重置
		        	      	dojo.byId('page_form').reset();
	
		        	      	  
		            	    dijit.byId('newPageRule').hide();
		        	        dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
						}
						if(data.s==400){
    	        			dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
    	        		}
        	        },
        	        error: function(error,ioargs){
					 
       	        	  var message = httpErrorReport(ioargs.xhr.status);
        	          dojo.byId("AlertCon2").innerHTML = message;
        	          dijit.byId("AlertShow2").show();
        	        }
        	      }
         
          	var deferred = dojo.xhrPost(xhrArgs);
        	
            return false;
        } else {
          
            return false;
        }
	</script>
		<input type="hidden" name="action" value="cache">
		<input type="hidden" name="op" value="savepagerule">
		<table style="width:500px;margin:10px">
		<thead>
		<tr >
		<td style="border-bottom:1px solid #ccc;width:150px;background-color:#eee">变量</td>
		<td style="border-bottom:1px solid #ccc;width:250px;background-color:#eee">值</td>
		<td style="border-bottom:1px solid #ccc;width:100px;background-color:#eee">备注</td>
		</tr>
		</thead>
		<tbody id="page_table">
	
		<tr id="row_rulename">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_rulename" value="rulename" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp='("[a-zA-Z0-9_]+")' invalidMessage='变量名不符合规则:("[a-zA-Z0-9_]+")' type="text" name="valu_rulename" id="valu_rulename" value=""></td>
		<td style="font-size:12px;color:#666"><label>规则名称</label></td>
		</tr>
		<tr id="row_cachestore">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_cachestore" value="cachestore" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp='("file"|"memcache")' invalidMessage='变量名不符合规则:("file"|"memcache")'  type="text" name="valu_cachestore" id="valu_cachestore" value='"file"'></td>
		<td style="font-size:12px;color:#666"><label>存储方式</label></td>
		</tr>
		<tr id="row_cacheserver">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_cacheserver" value="cacheserver" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" type="text" name="valu_cacheserver" id="valu_cacheserver" value=""></td>
		<td style="font-size:12px;color:#666"><label>Memcached服务器</label></td>
		</tr>
		
		<tr id="row_cachedir">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_cachedir" value="cachedir" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" type="text" name="valu_cachedir" id="valu_cachedir" value=""></td>
		<td style="font-size:12px;color:#666"><label>存储路径</label></td>
		</tr>
		
		<tr id="row_cachetime">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_cachetime" value="cachetime" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp="[0-9]+" invalidMessage="变量名不符合规则:[0-9]+" type="text" name="valu_cachetime" id="valu_cachetime" value=""></td>
		<td style="font-size:12px;color:#666"><label>缓存时间</label></td>
		</tr>
		
		<tr id="row_compressed">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_compressed" value="compressed" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp="[0|1]" invalidMessage="变量名不符合规则:[0|1]" type="text" name="valu_compressed" id="valu_compressed" value="1"></td>
		<td style="font-size:12px;color:#666"><label>缓存压缩</label></td>
		</tr>
		<tr id="row_action">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_action" value="action" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp='("[a-zA-Z0-9_]+")' invalidMessage='变量名不符合规则:("[a-zA-Z0-9_]+")' type="text" name="valu_action" id="valu_action" value=""></td>
		<td style="font-size:12px;color:#666"><label>$_GET['action']</label></td>
		</tr>	
		<tr id="row_view">
		<td><input dojoType="dijit.form.TextBox" style="width:150px" type="text" name="name_view" value="view" readonly></td>
		<td><input dojoType="dijit.form.ValidationTextBox" required="true" regExp='"[\w\,\*]+"' invalidMessage='变量名不符合规则:"[\w\,\*]+"' type="text" name="valu_view" id="valu_view" value='"*"'></td>
		<td style="font-size:12px;color:#666"><label>$_GET['view']</label></td>
		</tr>	
		</tbody>
		<tfoot>
		<tr>
		     <td colspan="2" align="center">
		       <button dojoType="dijit.form.Button" type="submit">保存</button>
		       <button dojoType="dijit.form.Button" type="reset">重置</button>
		       </td>
		   </tr>
		 </tfoot>	
		</table>
	</div>
</div>



<div dojoType="dijit.Dialog" id="editPageRule" title="修改规则" >

	<div method="" jsid="page_edit_form" id="page_edit_form" dojoType="dijit.form.Form" action="">
	
	<script type="dojo/method" event="onSubmit">
		if (this.validate()) {
            var xhrArgs = {
					url:gSiteUrl+"/index.php",
        	        form: 'page_edit_form',
        	        handleAs: "json",
        	        load: function(data){
            		//	alert(data);
    	        		if(data.s==200){
	    	        		
							//删除旧行
							var old_pagerule = dojo.byId("edit_pagerule").value;
							//alert(old_pagerule);
	            			dojo.byId("pagerulelist").removeChild(dojo.byId("page_"+old_pagerule));
	    	        		
			            	//新增行
			            	var rowid= "page_"+data.d;
			            	
			            	var rulename = data.d;
			            	
			            	var row=document.createElement("tr");   
			            	row.id= rowid; 
			
			            	var td = document.createElement("td");
			            	//var aNode = dojo.create("a", { href: "javascript:view_pagerule('"+host+"');", title: "view host!", innerHTML: host }); 
							var textNode = document.createTextNode(rulename);
			            	td.appendChild(textNode);
			            	
			            	row.appendChild(td);
			            	
			            	var td = document.createElement("td");
			            	var editbtn =new dijit.form.Button({label:"修改",onClick:function(){editPageRule(rowid,rulename)}});
			            	var deletebtn =new dijit.form.Button({label:"删除",onClick:function(){deletePageRule(rowid,rulename)}});
			            	td.appendChild(editbtn.domNode);
			            	td.appendChild(deletebtn.domNode);
			            	row.appendChild(td);		            	
			            	dojo.byId('pagerulelist').appendChild(row);
			            	
			            	//表单重置
		        	      	//dojo.byId('page_edit_form').reset();
	 	      	  
		            	    dijit.byId('editPageRule').hide();
		        	        dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
    	        		}
    	        		if(data.s==400){
    	        			dojo.byId("AlertCon2").innerHTML = data.m;
		        	        dijit.byId("AlertShow2").show();
    	        		}
        	        },
        	        error: function(error,ioargs){
					alert(error);
       	        	 var message = httpErrorReport(ioargs.xhr.status);
        	          dojo.byId("AlertCon2").innerHTML = message;
        	          dijit.byId("AlertShow2").show();
        	        }
        	      }
         
          	var deferred = dojo.xhrPost(xhrArgs);
        	
            return false;
        } else {
            
            return false;
        }
</script>
		<input type="hidden" name="action" value="cache">
		<input type="hidden" name="op" value="updatepagerule">
		<input type="hidden" name="edit_pagerule" id="edit_pagerule" value="">
		
		<table style="width:500px;margin:10px">
		<thead>
		<tr >
		<td style="border-bottom:1px solid #ccc;width:150px;background-color:#eee">变量</td>
		<td style="border-bottom:1px solid #ccc;width:250px;background-color:#eee">值</td>
		<td style="border-bottom:1px solid #ccc;width:100px;background-color:#eee">备注</td>
		</tr>
		</thead>
		<tbody id="page_edit_table">
		
		</tbody>
		<tfoot>
		<tr>
		     <td colspan="2" align="center">
		       <button dojoType="dijit.form.Button" type="submit">保存</button>
		       <button dojoType="dijit.form.Button" type="reset">重置</button>
		       </td>
		   </tr>
		 </tfoot>	
		</table>
	</div>
</div>




 

</body>
</html>